﻿using Newtonsoft.Json.Linq;

namespace Sustainalytics.LongRunningTaskManager.Interface
{
    /// <summary>
    /// Task param for accessing file manager file.
    /// </summary>
    public class FileManagerFileTaskParam : IFileManagerFileTaskParam
    {
        /// <summary>
        /// File manager file paths.
        /// </summary>
        public string[] FileManagerFilePaths { get; set; }


        /// <summary>
        /// Add current instance values to task params JSON string.
        /// </summary>
        /// <param name="paramsJson"> Task params JSON. </param>
        public string AddToParamsJson(string paramsJson)
        {
            JObject jsonObj;

            if (string.IsNullOrEmpty(paramsJson))
            {
                jsonObj = new JObject();
            }
            else
            {
                jsonObj = JObject.Parse(paramsJson);
            }

            jsonObj["fileManagerFilePaths"] = JToken.FromObject(this.FileManagerFilePaths);

            string json = jsonObj.ToString();

            return json;
        }
    }
}
